Repository navigation
Controller as keyboard for games without controller support - #39
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: a game that only understands a keyboard could not be played on the TV with a controller, and the shared keyboard is blocked during isolation anyway.
After: Controllers has a "Controller as keyboard" card. Each button, trigger and left-stick direction can press a key inside the isolated game (a WASD preset is one click). The shared keyboard stays blocked; only these keys reach the game, and nothing is sent to other programs.
How: a thread in the hook reads the game's player 1 (tuning applied) about 125 times per second and posts WM_KEYDOWN/WM_KEYUP to the game window with a marker bit in lParam, which the keyboard block and the window shield let through (marker removed before the game's window procedure). GetAsyncKeyState, GetKeyState and GetKeyboardState report these keys as pressed. The key map travels in the tuning message (protocol 7, 72 bytes). Games that read the keyboard through Raw Input or DirectInput are not covered; the card says so.